# Generated by Django 3.2.13 on 2022-04-13 18:28

from django.db import migrations, models
from django.db.models import F, Value
from django.db.models.functions import Concat

import apps


def forward(apps, schema_editor):
    """
    Reformat data for the new FieldType
    """
    UserProfile = apps.get_model("user", "UserProfile")
    UserProfile.objects.update(
        activity_cantons=Concat(Value("{"), F("activity_cantons"), Value("}"))
    )


class Migration(migrations.Migration):
    dependencies = [
        ("user", "0070_userprofile_updated_at"),
    ]

    operations = [
        migrations.RunPython(forward),
        migrations.AlterField(
            model_name="userprofile",
            name="activity_cantons",
            field=apps.user.models.ChoiceArrayField(
                base_field=models.CharField(
                    choices=[
                        ("AG", "Aargau"),
                        ("AR", "Appenzell Ausserrhoden"),
                        ("BS", "Basel-Stadt"),
                        ("BL", "Basel-Land"),
                        ("BE", "Berne"),
                        ("FR", "Fribourg"),
                        ("GE", "Geneva"),
                        ("GR", "Graubuenden"),
                        ("JU", "Jura"),
                        ("LU", "Lucerne"),
                        ("NE", "Neuchatel"),
                        ("SZ", "Schwyz"),
                        ("SO", "Solothurn"),
                        ("SG", "St. Gallen"),
                        ("VS", "Valais"),
                        ("VD", "Vaud"),
                        ("ZG", "Zug"),
                        ("ZH", "Zurich"),
                    ],
                    max_length=2,
                ),
                blank=True,
                default=list,
                size=None,
                verbose_name="Défi Vélo mobile",
            ),
        ),
    ]
